package ANDROID_RLK_MEDIARECORDER;

public class Fixed {
    public boolean onKeyDown(final int keyCode, final KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_ENTER) {
            MediaRecorder recorder = new MediaRecorder();
            try {
                recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
                recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
                recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
                recorder.setOutputFile(PATH_NAME);
                recorder.prepare();
                recorder.start();   // Recording is now started
                recorder.stop();
                recorder.reset();   // You can reuse the object by going back to setAudioSource() step
            } finally {
                recorder.release();
            }
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}
